#include <iostream>
#include "UdpServer.h"
#include <thread>
#include <signal.h>
#ifdef _WIN32
    #pragma comment(lib,"ws2_32.lib")
#endif

static volatile bool g_runFlag = true;
void sighandler(int signum)
{
    g_runFlag = false;
}

int main(int argc, const char *argv[])
{

#ifdef _WIN32
{
    WORD wVersionRequested;
    WSADATA wsaData;
    wVersionRequested = MAKEWORD(2, 2);
    WSAStartup(wVersionRequested, &wsaData);
}
#endif

    UdpServer server;
    server.init("0.0.0.0", 9999);
    server.start();

    signal(SIGINT, sighandler);

    while (g_runFlag)
    {
        std::this_thread::sleep_for(std::chrono::seconds(2));
    }

#ifdef _WIN32
    WSACleanup();
#endif
    return 0;
}
